package com.bawei.lizhiyu1228.ui.act;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.bawei.lizhiyu1228.R;
import com.bawei.lizhiyu1228.greendao.DaoManager;
import com.bawei.lizhiyu1228.greendao.Foots;
import com.blankj.utilcode.util.ToastUtils;
import com.bumptech.glide.Glide;

public class FootActivity extends AppCompatActivity {

    private ImageView footsIm;
    private TextView footsTv;
    private Button footsBnt;
    private Button footsShop;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_foot);
        initView();


        Intent intent = getIntent();
        String pic = intent.getStringExtra("pic");
        String tv = intent.getStringExtra("tv");

        Glide.with(this).load(pic).override(400, 400).into(footsIm);
        footsTv.setText(tv);

        footsBnt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                DaoManager.getInstance().getDaoSession().insert(new Foots(pic, tv));

                ToastUtils.showShort("加入购物车");
            }
        });

        footsShop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent1 = new Intent(getApplication(), DaoActivity.class);
                startActivity(intent1);
            }
        });

    }

    private void initView() {
        footsIm = (ImageView) findViewById(R.id.foots_im);
        footsTv = (TextView) findViewById(R.id.foots_tv);
        footsBnt = (Button) findViewById(R.id.foots_bnt);
        footsShop = (Button) findViewById(R.id.foots_shop);
    }
}